package com.itfreer.gis.map.resource;

import com.itfreer.form.api.DictionaryServiceImp;
import com.itfreer.form.api.dictionary.DictionaryEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.itfreer.form.api.BaseDao;
import com.itfreer.gis.map.resource.dao.CustomDataDao;
import com.itfreer.gis.map.resource.entity.CustomDataEntity;

/**
 * 栅格数据
 */
@Component
@Service(interfaceClass = CustomDataService.class, path = "giscustomdata")
public class CustomDataServiceImp extends DictionaryServiceImp<CustomDataEntity> implements CustomDataService {

	@Autowired
	private CustomDataDao dao;

	@Override
	protected BaseDao<CustomDataEntity> getDao() {
		return dao;
	}

	/**
	 * 是否为租户间共享实体对象
	 */
	protected boolean isShareTenant() {
		return true;
	}

	/**
	 * 获取租户间共享字段名称 用于SAAS下数据管理
	 */
	protected String getShareTenantFieldName() {
		return "shareTenantID";
	}

	@Override
	public String getDictionaryName() {
		return "g_grid_data";
	}

	@Override
	protected DictionaryEntity convert(CustomDataEntity entity) {
		DictionaryEntity toEntity = new DictionaryEntity();
		toEntity.setId(entity.getId());
		toEntity.setCode(entity.getId());
		toEntity.setDisplay(entity.getName());
		toEntity.setTenantID(entity.getTenantID());
		toEntity.setTenantName(entity.getTenantName());
		toEntity.setShareTenantID(entity.getShareTenantID());
		return toEntity;
	}

	@Override
	protected String getDictionaryFields() {
		return "*";
	}
}
